package cn.gemiman.daoyi.module.netty.server.mqtt.options;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author Gemiman
 * @date 2021/10/4 14:58
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CustomMqttPublishMessage {
    private String channelId;
    private String topic;
    private String content;

    public boolean isEmpty() {
        return channelId == null || channelId.isEmpty() || topic == null || topic.isEmpty() || content == null || content.isEmpty();
    }

    @Override
    public String toString() {
        String temp = content.length() < 300 ? content : (content.substring(0, 300) + "......");
        return "\n{\n" +
                //"channelId='" + channelId + '\'' +
                "   topic='" + topic + '\'' +
                ",\n   content='" + temp + '\'' +
                "\n}";
    }
}
